//
//  FirstPageViewController.m
//  jinritoutiao
//
//  Created by 汤环 on 2025/8/13.
//

#import "FirstPageViewController.h"
#import "NewsContentTableViewCell.h"

@interface FirstPageViewController ()
@property (nonatomic, strong) UITableView *newsContentTableView;
@end

@implementation FirstPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tabBarItem.title = @"首页";
    self.tabBarItem.image = [UIImage imageNamed:@"home"];
    self.view.backgroundColor = [UIColor whiteColor];
    
    // 设置 TableView
    self.newsContentTableView.dataSource = self;
    self.newsContentTableView.delegate = self;
    [self.newsContentTableView registerClass:[NewsContentTableViewCell class] forCellReuseIdentifier:@"newsContentTableViewCell"];
    
    // 设置 TableView 的 frame
    self.newsContentTableView.frame = self.view.bounds;
    
    // 添加 TableView 到视图
    [self.view addSubview:self.newsContentTableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100.0; // 设置 Cell 高度为 60
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NewsContentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"newsContentTableViewCell" forIndexPath:indexPath];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(UITableView*)newsContentTableView{
    if(!_newsContentTableView)
    {
        _newsContentTableView = [[UITableView alloc]init];
    }
    return _newsContentTableView;
}
@end
